package com.cloudservice.ccs.biz.impl;

import com.cloudservice.ccs.biz.IAttendanceStatisticsBiz;
import com.cloudservice.ccs.entity.AttendanceStatistics;
import com.cloudservice.ccs.exception.AttendanceStatisticsException;
import com.cloudservice.ccs.exception.BlackListException;
import com.cloudservice.ccs.mapper.AttendanceStatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AttendanceStatisticsImpl implements IAttendanceStatisticsBiz {
    @Autowired
    private AttendanceStatisticsMapper attendanceStatisticsMapper;
    @Override
    public void save(AttendanceStatistics attendanceStatistics) {
        int result = attendanceStatisticsMapper.save(attendanceStatistics);
        if (result == 0) {
            throw new AttendanceStatisticsException("Create AttendanceStatistics entity error");
        }
    }

    @Override
    public void update(Integer id, AttendanceStatistics attendanceStatistics) {
        int result = attendanceStatisticsMapper.update(id, attendanceStatistics);
        if (result == 0) {
            throw new AttendanceStatisticsException("Update AttendanceStatistics entity error");
        }
    }

    @Override
    public void partialUpdate(Integer id, Map<String, Object> fields) {
        int result = attendanceStatisticsMapper.partialUpdate(id, fields);
        if (result == 0) {
            throw new AttendanceStatisticsException("Update AttendanceStatistics entity error");
        }
    }

    @Override
    public void delete(Integer id) {
        int result = attendanceStatisticsMapper.delete(id);
        if (result == 0) {
            throw new AttendanceStatisticsException("Delete AttendanceStatistics entity error");
        }
    }

    @Override
    public AttendanceStatistics getOne(Integer id) {
        AttendanceStatistics attendanceStatistics = attendanceStatisticsMapper.getOne(id);
        if (attendanceStatistics == null) {
            throw new AttendanceStatisticsException("Get AttendanceStatistics entity error: no such entity");
        }
        return attendanceStatistics;
    }

    @Override
    public List<AttendanceStatistics> getAll() {
        return attendanceStatisticsMapper.getAll();
    }
}
